package com.mantou.mantouaiagent.rag.document.writer.vectorstore;

import com.mantou.mantouaiagent.rag.document.reader.LoveAppDocumentLoader;
import com.mantou.mantouaiagent.rag.document.transformer.MyKeywordEnricher;
import com.mantou.mantouaiagent.rag.document.transformer.MyTokenTextSplitter;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;

/**
 * pgVector 配置
 */
@Configuration
public class PgVectorVectorStoreConfig {

    @Resource
    private LoveAppDocumentLoader loveAppDocumentLoader;

    @Resource
    private MyTokenTextSplitter myTokenTextSplitter;

    @Resource
    private MyKeywordEnricher myKeywordEnricher;

////    @Bean
//    public VectorStore pgVectorVectorStore(JdbcTemplate jdbcTemplate, EmbeddingModel dashscopeEmbeddingModel) {
//        VectorStore vectorStore = PgVectorStore.builder(jdbcTemplate, dashscopeEmbeddingModel)
//                .dimensions(1536)                    // Optional: defaults to model dimensions or 1536
//                .distanceType(COSINE_DISTANCE)       // Optional: defaults to COSINE_DISTANCE
//                .indexType(HNSW)                     // Optional: defaults to HNSW
//                .initializeSchema(true)              // Optional: defaults to false
//                .schemaName("public")                // Optional: defaults to "public"
//                .vectorTableName("vector_store")     // Optional: defaults to "vector_store"
//                .maxDocumentBatchSize(10000)         // Optional: defaults to 10000
//                .build();
//        // 抽取文档
//        List<Document> documents = loveAppDocumentLoader.loadMarkdowns();
//
//        //手动拆分文档
//        List<Document> splitDocument = myTokenTextSplitter.splitCustomized(documents);
//
//        //通过ai添加元数据关键词
//        List<Document> enrichDocuments = myKeywordEnricher.enrichDocuments(splitDocument);
//
//        vectorStore.add(enrichDocuments);
//        return vectorStore;
//    }
}
